package com.slz3.business.frame.conf;

import com.slz3.business.frame.redis.RK;
import com.slz3.business.module.memberManagement.Feedback.steward.MemFeedBackSync;
import com.slz3.business.module.memberManagement.drawTicket.steward.DrawTicketBackSync;
import com.slz3.business.module.memberManagement.memMember.steward.MemMemberSynr;
import com.slz3.business.module.memberManagement.memShoppingCar.steward.MemShoppingCarSynr;
import com.slz3.business.module.memberManagement.memThirdLoginInfo.steward.MemThirdLoginInfoBackSync;
import com.slz3.business.module.memberManagement.userScoreRecord.steward.UserScoreRecordBackSync;
import com.slz3.business.module.orderManagement.ordOrder.steward.OrdOrderSynr;
import com.slz3.business.module.orderManagement.ordRefund.steward.OrdRefundSynr;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;


@Component
@Slf4j
public class Receiver implements MessageListener {

    @Override
    public void onMessage(Message message, byte[] pattern) {

        String patternTopicName = new String(pattern);
        //根据消息队列不同的key进行不同的操作
        switch (patternTopicName) {
            case RK.USER_USERREGIST: //用户注册
                MemMemberSynr.memMemberAdd();
                break;
            case RK.USER_SHOPPTING_ADDCAR: //用户购物车增加
                MemShoppingCarSynr.memShoppingCarAdd();
                break;
            case RK.SHOPPTING_CAR_DELETE://购物车删除
                MemShoppingCarSynr.memShoppingCarDelete();
                break;
            case RK.SHOPPTING_CAR_MODIFY://购物车修改
                MemShoppingCarSynr.memShoppingCarModify();
                break;
            case RK.SAVE_ORDER://订单下单
                OrdOrderSynr.ordOrderAdd();
                break;
            case RK.ORDER_DELETE://订单删除
                OrdOrderSynr.ordOrderDelete();
                break;
            case RK.CLOSE_ORDER://取消订单
                OrdOrderSynr.ordOrderClose();
                break;
            case RK.CONFIRM_RECEIVER://取消订单
                OrdOrderSynr.confirmReceiver();
                break;
            case RK.JIFEN_PAY://积分支付
                OrdOrderSynr.ordOrderJifenPay();
                break;
            case RK.APPPAY_ALIPAYUPDATE://支付宝支付
                OrdOrderSynr.ordOrderAliPay();
                break;
            case RK.APPPAY_WEIXINPAYUPDATE://微信支付
                OrdOrderSynr.ordOrderWeixinPay();
                break;
            case RK.ORDERRETURN_APPLYAFTERSALELIST://申请售后
                OrdRefundSynr.ordRefundAdd();
                break;
            case RK.ORDERRETURN_RECALLREFUNDLIST://取消售后申请
                OrdRefundSynr.cancelRefund();
                break;
            case RK.ORDERRETURN_DELIVERLIST://售后用户发货
                OrdRefundSynr.refundDeliver();
                break;
            case RK.FEED_BACK_LIST: // 会员意见反馈
                MemFeedBackSync.syncData();
                break;
            case RK.JI_FEN_RECORD: // 积分
                UserScoreRecordBackSync.syncData();
                break;
            case RK.DRAW_TICKET_LIST: // 抽奖券
                DrawTicketBackSync.syncData();
                break;
            case RK.User_THIRD: // 第三方用户同步
                MemThirdLoginInfoBackSync.syncData();
                break;
            default:
                break;
        }
    }

}
